package com.leo.foodmaster.admin.stock.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.leo.foodmaster.admin.stock.entity.WarehouseInRecord;
import com.leo.foodmaster.admin.stock.entity.WarehouseStock;
import com.leo.foodmaster.admin.stock.service.IWarehouseStockService;
import com.leo.foodmaster.commons.entity.Result;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 仓库库存Controller
 * </p>
 *
 * @author ：Leo
 * @since ：2021/9/19 18:29
 */
@RestController
@AllArgsConstructor
@RequestMapping("/stock/warehouseStock")
public class WarehouseStockController {
    private final IWarehouseStockService warehouseStockService;

    @ApiOperation("条件分页查询仓库库存列表")
    @GetMapping("/list")
    public Result<IPage<WarehouseStock>> getWarehouseStockPageList(
            @ApiParam(value = "当前页，从1开始", required = true) @RequestParam Integer pageNum,
            @ApiParam(value = "每页记录数", required = true) @RequestParam Integer pageSize,
            @ApiParam(value = "仓库Id") @RequestParam(required = false) Long warehouseId,
            @ApiParam(value = "食材名称") @RequestParam(required = false) String foodMaterialName,
            @ApiParam(value = "食材类型Id") @RequestParam(required = false) Long foodMaterialTypeId
    ) {
        IPage<WarehouseStock> pageList  = warehouseStockService
                .getWarehouseStockPageList(new Page<>(pageNum, pageSize), warehouseId,
                        foodMaterialName, foodMaterialTypeId);
        return Result.success(pageList);
    }
}
